package com.qf.day02;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author lixu
 */
public class CollectionDemo {

    public static void main(String[] args) {
        //List list = new ArrayList<>();
        //JUC包下的
        List list = Collections.synchronizedList(new ArrayList<>());

        for (int i = 0; i < 10; i++) {
            String is = String.valueOf(i);
            new Thread(() -> {
                list.add(is);
                System.out.println(list);
                //Exception in thread "7" java.util.ConcurrentModificationException
            },is).start();
        }
    }
}
